<template>
	<view>
		<navbar title='闪兑' type='4'></navbar>
		<view class="label">
			<view class="label_text">从TOPS</view>
			<view class="textinput flex-between">
				<input type="digit" v-model="num" @input='$u.throttle(inputChange,500)' placeholder="请输入数量"
					placeholder-class="phone" />
				<view class="flex" style="align-items: center;">
					<view class="text2">全部</view>
				</view>
			</view>
		</view>
		<view class="allmoney">总余额：123456789.12</view>
		<view class="cut">
			<image src="../../static/wallet/cut.png" mode="" @click="exchange"></image>
		</view>
		<view class="label">
			<view class="label_text flex" @click="showtype=true">到{{paytype}}
				<image src="../../static/wallet/down.png"></image>
			</view>
			<view class="textinput flex-between">
				<input type="digit" v-model="num1" @input='$u.throttle(inputChange,500)' placeholder="请输入数量"
					placeholder-class="phone" />
			</view>
		</view>
		<u-picker :show="showtype" :columns="columnstype" keyName='nmae' @confirm="confirm"
			@cancel="showtype=false"></u-picker>
		<view class="cutnum">1TOPS≈1USDT</view>
		<view :class="logining?'isbtn istext':'istext'" @click="logining?tocut():''">
			闪兑
		</view>
	</view>
</template>

<script>
	import navbar from "@/components/navbar.vue"
	export default {
		components: {
			navbar
		},
		data() {
			return {
				num: 0,
				num1: 0,
				ratio: 0.9,
				logining: false,
				showtype: false,
				columnstype: [
					[{
						nmae: 'USDT',
						id: 1
					}, {
						nmae: 'TOPS',
						id: 2
					}]
				],
				fromAccount: '',
				toAccount: ''
			}
		},
		onLoad() {
			this.paytype = this.columnstype[0][0].nmae
		},
		methods: {
			inputChange() {
				const {
					num,
					num1
				} = this
				if (num !== '' && num1 !== '') {
					this.logining = true
				} else {
					this.logining = false
				}
			},
			confirm(e) {
				console.log(e)
				this.paytype = e.value[0].nmae
				this.showtype = false
			},
			clickFromActionSheet(i) {
				const {
					fromAccounts,
					toAccount
				} = this
				if (fromAccounts[i].id == toAccount.id) {
					this.exchange()
				} else {
					this.fromAccount = fromAccounts[i]
				}
				this.calcBalance()
			},
			clickToActionSheet(i) {
				const {
					fromAccount,
					toAccounts
				} = this
				if (toAccounts[i].id == fromAccount.id) {
					this.exchange()
				} else {
					this.toAccount = toAccounts[i]
				}
			},
			exchange() {
				const change = this.fromAccount
				this.fromAccount = this.toAccount
				this.toAccount = change
			},
			tocut() {

			}
		}
	}
</script>

<style lang="scss">
	.label {
		width: 690rpx;
		box-sizing: border-box;
		margin: 0 auto 0;
		padding-top: 30rpx;

		&_text {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
			line-height: 28rpx;
			text-align: left;
			font-style: normal;

			image {
				width: 28rpx;
				height: 28rpx;
			}
		}

		.textinput {
			width: 690rpx;
			height: 80rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			padding: 0 20rpx;
			box-sizing: border-box;
			margin-top: 20rpx;
			margin-bottom: 20rpx;
			align-items: center;

			.text1 {
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
			}

			.text2 {
				font-weight: 500;
				font-size: 28rpx;
				color: #9999FF;
			}
		}

		.img1 {
			width: 2rpx;
			height: 40rpx;
			margin: 0 20rpx;
		}

		.img2 {
			width: 28rpx;
			height: 28rpx;
		}

		.istipcol {
			color: #999999;
		}

		.phone,
		.password {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #CCCCCC;
			text-align: left;
			font-style: normal;
		}
	}

	.allmoney {
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;
		margin-left: 30rpx;
		margin-bottom: 30rpx;
	}

	.cut {
		width: 48rpx;
		height: 48rpx;
		margin: 0 auto;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.cutnum {
		font-weight: 500;
		font-size: 28rpx;
		color: #333333;
		text-align: center;
		margin: 90rpx 0 30rpx;
	}

	.istext {
		width: 690rpx;
		height: 88rpx;
		border-radius: 44rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #CCCCCC;
		line-height: 88rpx;
		text-align: left;
		font-style: normal;
		text-align: center;
		margin: 0 auto 0;
	}

	.isbtn {
		background: $uni-color-primary;
		color: #FFFFFF;
	}
</style>